#include<bits/stdc++.h>
using namespace std;
int T,n,a[25],maxn,b[25];
void dfs(int deep){
	if(deep==n+1){
		int ans=0;
		for(int i=1;i<=n;i++){
			int k=114514;
			for(int j=i-1;j>=1;j--){
				if(b[i]==b[j]){
					if(a[i]==a[j]) k=i;
					break;
				}
			}
			if(k!=114514) ans+=a[k];
		}
		maxn=max(maxn,ans);
		return;
	}
	b[deep+1]=0;
	dfs(deep+1);
	b[deep+1]=1;
	dfs(deep+1);
	return;
}
int main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	cin>>T;
	while(T--){
		cin>>n;
		maxn=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			b[i]=0;
		}
		dfs(1);
		cout<<maxn<<endl;
	}
	return 0;
}
// 20pts for fr e e eeee eeeee e eeee !!!
// I think I would be able to get 2= ha ha hahahaha hahahahaha ha hahahaha
// 114514 114514 114514114514114514114514 114514114514114514114514114514 114514 114514114514114514114514
